package com.myself.cloud.entity;

import java.io.Serializable;
import java.util.List;

/**
 * jrmm
 *
 */
public class BasePage<T> implements Serializable {

    private long totalElements;
    private long pageNumber;
    private long pageSize;
    private long totalPages;
    private List<T> elements;

    public long getTotalPages() {
        if (this.pageSize == 0L) {
            return 0L;
        }
        if (this.totalElements == 0L) {
            return 0L;
        }
        long pages = this.totalElements / this.pageSize;
        if (this.totalElements % this.pageSize != 0L) {
            ++pages;
        }
        this.totalPages = pages;
        return totalPages;

    }

    public long getTotalElements() {
        return totalElements;
    }

    public void setTotalElements(long totalElements) {
        this.totalElements = totalElements;
    }

    public long getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(long pageNumber) {
        this.pageNumber = pageNumber;
    }

    public long getPageSize() {
        return pageSize;
    }

    public void setPageSize(long pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getElements() {
        return elements;
    }

    public void setElements(List<T> elements) {
        this.elements = elements;
    }

    public void setTotalPages(long totalPages) {
        this.totalPages = totalPages;
    }
}
